package com.vnp.vchat.adapter;

import java.util.ArrayList;

import com.vnp.vchat.R;
import com.vnp.vchat.util.Utils;

import android.content.Context;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class SourceAdapter extends ArrayAdapter<String> {

	Context context;
	ArrayList<String> listSource = new ArrayList<String>();

	public SourceAdapter(Context context, ArrayList<String> listSource) {
		super(context, R.layout.item_listview_pop_up, listSource);
		this.context = context;
		this.listSource = listSource;
	}

	@Override
	public int getCount() {
		return listSource.size();
	}

	@Override
	public String getItem(int position) {
		return listSource.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View v, ViewGroup parent) {
		Holder holder = null;
		if (v==null){
			LayoutInflater inflater = LayoutInflater.from(getContext());
			v = inflater.inflate(R.layout.item_listview_pop_up, parent, false);
			holder = new Holder();

			holder.txtSource = (TextView) v.findViewById(R.id.txt_name_source);
			
			v.setTag(holder);
		} else {
			holder = (Holder) v.getTag();
		}
		
		holder.txtSource.setTypeface(Utils.getTypefaceRegular(context), Typeface.BOLD);
		
		holder.txtSource.setText(listSource.get(position));
		
		return v;
	}
	
	class Holder{
		TextView txtSource;
	}
	
	

}
